package com.xnyzc.lhy.finance.service.impl.bank;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xnyzc.lhy.finance.entity.bank.OaSysCpBank;
import com.xnyzc.lhy.finance.mapper.bank.OaSysCpBankMapper;
import com.xnyzc.lhy.finance.service.bank.IOaSysCpBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author haoyfa
 * @since 2019-11-16
 */
@Service
public class OaSysCpBankServiceImpl extends ServiceImpl<OaSysCpBankMapper, OaSysCpBank> implements IOaSysCpBankService {
    /**
     * 根据银行名称查询银行信息
     * @param bankName
     * @return
     */
    @Override
    public OaSysCpBank getCpBankCode(String bankName){
        // 查询机构角色关联
        QueryWrapper<OaSysCpBank> queryWrapper = new QueryWrapper<OaSysCpBank>();
        queryWrapper.eq(OaSysCpBank.BANK_NAME, bankName);
        List<OaSysCpBank> cpBankList = this.baseMapper.selectList(queryWrapper);

        if (cpBankList != null
                && cpBankList.size() > 0) {
            return cpBankList.get(0);
        } else {
            return null;
        }
    }
}
